#include<bits/stdc++.h>
using namespace std;
int n;
int solve(int num)
{
    int ret=0;
    while(num)
    {
        ret++;
        num=num&(num-1);
    }
    return ret;
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        int num;
        cin>>num;
        cout<<solve(num)<<" ";
    }
    return 0;
}